package com.efounder.form.comp.shoppingcar;

import android.app.Activity;
import android.os.Bundle;
import androidx.recyclerview.widget.RecyclerView;
import android.widget.LinearLayout;


import com.efounder.builder.base.data.EFDataSet;
import com.efounder.builder.base.data.EFRowSet;
import com.efounder.mobilecomps.R;

/**
 * Created by XinQing on 2016/9/13.
 */

public class TestShoppingCardRecyclerViewActivity extends Activity{

    private RecyclerView recyclerView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_test_title_recyler_view);

        LinearLayout rootLayout = (LinearLayout) findViewById(R.id.rootLayout);
        rootLayout.addView(new ShoppingCar(this,getEFData()));


//        recyclerView = (RecyclerView) findViewById(R.id.recycler_view);

//        LinearLayoutManager layoutManager = new LinearLayoutManager(this);
//        //设置布局管理器
//        recyclerView.setLayoutManager(layoutManager);
//        //设置为垂直布局，这也是默认的
//        layoutManager.setOrientation(OrientationHelper.VERTICAL);
//        //设置分隔线
//        recyclerView.addItemDecoration(new DividerItemDecoration(this, DividerItemDecoration.VERTICAL_LIST));
//        //设置增加或删除条目的动画
//        recyclerView.setItemAnimator( new DefaultItemAnimator());
//        //设置Adapter
//        ShoppingCarCategoryAdapter adapter = new ShoppingCarCategoryAdapter(this,getEFData());
//        recyclerView.setAdapter(adapter);


    }

    private EFRowSet getEFData(){
        EFRowSet rootRowSet = new EFRowSet();

        EFDataSet dataSet = null;
        EFRowSet rowSet = null;

        //=================柴油=================EFDataSet
        dataSet = new EFDataSet();
        dataSet.setTableName("柴油");

        rowSet  = new EFRowSet();
        rowSet.putString("name","0#");
        rowSet.putString("description","普通柴油");
        rowSet.putNumber("count",1);
        rowSet.putString("price","￥ 1.1");
        rowSet.putString("unit","升");
        dataSet.addRowSet(rowSet);

        rowSet  = new EFRowSet();
        rowSet.putString("name","-10#");
        rowSet.putString("description","车用柴油");
        rowSet.putNumber("count",2);
        rowSet.putString("price","￥ 2.2");
        rowSet.putString("unit","升");
        dataSet.addRowSet(rowSet);

        rootRowSet.setDataSet(dataSet.getTableName(),dataSet);
        //=================柴油=================EFDataSet
        //=================汽油=================EFDataSet
        dataSet = new EFDataSet();
        dataSet.setTableName("汽油");

        rowSet  = new EFRowSet();
        rowSet.putString("name","95#");
        rowSet.putString("description","普通汽油");
        rowSet.putNumber("count",1);
        rowSet.putString("price","￥ 1.1");
        rowSet.putString("unit","升");
        dataSet.addRowSet(rowSet);

        rowSet  = new EFRowSet();
        rowSet.putString("name","97#");
        rowSet.putString("description","车用汽油");
        rowSet.putNumber("count",2);
        rowSet.putString("price","￥ 2.2");
        rowSet.putString("unit","升");
        dataSet.addRowSet(rowSet);

        rootRowSet.setDataSet(dataSet.getTableName(),dataSet);
        //=================汽油=================EFDataSet
        //=================沥青=================EFDataSet
        dataSet = new EFDataSet();
        dataSet.setTableName("沥青");

        rowSet  = new EFRowSet();
        rowSet.putString("name","50号");
        rowSet.putString("description","道路石油沥青");
        rowSet.putNumber("count",1);
        rowSet.putString("price","￥ 1.1");
        rowSet.putString("unit","吨");
        dataSet.addRowSet(rowSet);

        rowSet  = new EFRowSet();
        rowSet.putString("name","70号");
        rowSet.putString("description","道路石油沥青");
        rowSet.putNumber("count",2);
        rowSet.putString("price","￥ 2.2");
        rowSet.putString("unit","吨");
        dataSet.addRowSet(rowSet);

        rowSet  = new EFRowSet();
        rowSet.putString("name","90号");
        rowSet.putString("description","道路石油沥青");
        rowSet.putNumber("count",3);
        rowSet.putString("price","￥ 3.3");
        rowSet.putString("unit","吨");
        dataSet.addRowSet(rowSet);

        rootRowSet.setDataSet(dataSet.getTableName(),dataSet);
        //=================汽油=================EFDataSet


        return rootRowSet;
    }



}
